home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / clipper / nannws13.zip / CLIPMEM.PRG next >
Text File  |  1987-05-22  |  6KB  |  209 lines

  1. * CLIPMEM.PRG
  2. * Date:   February 1987
  3. * Author: David Morgan
  4. * Notes:  Simulates Clipper Autumn '86 memory allocation
  5. *          groundrules explained in Nantucket News, Autumn
  6. *          1986, p. 4.
  7. *         Requires DOS 3.x or greater for assembly routines
  8. * Input:  configuration information about machine environment
  9. *          as follows --
  10. *
  11. *         tot_conv = amount of conventional memory installed (K)
  12. *         tot_exp  = amount of expanded memory installed
  13. *         dos_size = size of DOS as loaded at runtime
  14. *         load_module = size of your application's load module
  15. *         CLIPPER  = copy of the runtime CLIPPER environment
  16. *                    string
  17. *
  18. * Output: memory allocation/distribution information as follows
  19. *
  20. *         X         = amt of mem excluded
  21. *         mem_vars  = amt of mem devoted to storing memvars
  22. *         run_space = amt of mem for RUNning/perhaps indexing
  23. *         pool      = amt of memory devoted to free pool
  24. *         exp_space = amt of expanded mem. devoted to indexing
  25. *                     if zero, indexing shares run_space
  26. *                     otherwise run_space is for exclusive use
  27. *                     by RUN commands
  28. *
  29.  
  30. PARAMETERS tot_conv,tot_exp,dos_size,load_module
  31. param_count = PCOUNT()
  32. CLEAR
  33. CLIPPER=UPPER(GETE('CLIPPER')+' ')
  34. numerals = '1234567890'
  35. params = 'VREX'
  36. error = .F.
  37. DO CASE
  38.  CASE param_count=0    && get parameters from this machine
  39.   tot_conv = MEM_AMT()  
  40.   tot_conv = 16 * iif(tot_conv<0,65536+tot_conv,tot_conv) / 1024
  41.   tot_conv = (INT(tot_conv+.5))
  42.   tot_exp = 16*EM_AMT()
  43.   dos_size = 16*DOS_SIZ()/1024
  44.   dos_size = (INT(dos_size+.5))
  45.   load_module = 0
  46.   @ 6,0
  47.   TEXT
  48.   CLIPMEM will read remaining memory configuration parameters
  49.    from this machine.
  50.  
  51.  
  52.   Alternative calling syntax you may use to specify parameters
  53.    yourself, reflecting any machine:
  54.  
  55.   CLIPMEM tot_conv tot_exp dos_size load_module
  56.   ENDTEXT
  57.   @ 4,0 SAY 'What is the load module size? ' GET load_module;
  58.    RANGE 100,600
  59.   READ
  60.  CASE param_count=4    && take parameters from command line
  61.   tot_conv=VAL(tot_conv)
  62.   tot_exp=VAL(tot_exp)
  63.   dos_size=VAL(dos_size)
  64.   load_module =VAL(load_module)
  65.  OTHERWISE
  66.   DO TERMINATE
  67. ENDCASE
  68.  
  69. * range checking
  70. DO CASE
  71.  CASE tot_conv<256 .OR. tot_conv>640
  72.   error = .T.
  73.  CASE tot_exp<0 .OR. tot_exp>8192
  74.   error = .T.
  75.  CASE dos_size<20 .OR. dos_size>200
  76.   error = .T.
  77.  CASE load_module<100 .OR. load_module>600
  78.   error = .T.
  79. ENDCASE
  80. IF error
  81.  DO TERMINATE
  82. ENDIF
  83.  
  84. * analyze CLIPPER string
  85. p2 = 1
  86. DO WHILE p2 <= 4
  87.  curr_par = SUBSTR(params, p2, 1)
  88.  error = .F.
  89.  IF AT('&curr_par',CLIPPER)>0
  90.   p1 = AT('&curr_par',CLIPPER)+1
  91.   no_chars = 0
  92.   DO WHILE SUBSTR(CLIPPER,P1,1)$numerals
  93.    no_chars = no_chars + 1
  94.    p1 = p1 + 1
  95.   ENDDO
  96.   error = IIF(no_chars=0, .T., .F.)
  97.   IF .NOT.error
  98.    &curr_par = VAL(SUBSTR(CLIPPER,p1-no_chars,no_chars))
  99.   ELSE
  100.    CLEAR
  101.    ? 'Error in CLIPPER string format. Calculation canceled.'
  102.    CANCEL
  103.   ENDIF
  104.  ELSE
  105.   &curr_par=0
  106.  ENDIF
  107.  p2 = p2 + 1
  108. ENDDO :p2<=4
  109.  
  110. * follow the groundrules to calculate each memory category
  111. left_over = tot_conv - dos_size - load_module
  112. excluded = X
  113. left_over = left_over - excluded
  114. pool=24
  115. left_over = left_over - pool
  116. mem_vars = IIF(V>0,V,IIF( .2*left_over > 44 , 44, .2*left_over))
  117. left_over = left_over - mem_vars
  118. run_space = IIF(R > 0 ,  R, left_over/3 )
  119. run_space = IIF(tot_exp=0.AND.run_space < 16, 16, run_space)
  120. left_over = left_over - run_space
  121. pool = pool + left_over
  122.  
  123. IF AT('E',CLIPPER) > 0               && 'E' param present
  124.  IF E=0
  125.   exp_space = 0
  126.  ELSE
  127.   exp_space = E                       && E specified, but
  128. * can't exceed 1MB:
  129.   exp_space = IIF(exp_space>1024, 1024, exp_space)
  130. * or EMM total:
  131.   exp_space = IIF(exp_space>tot_exp, tot_exp, exp_space)
  132. * need 16K at least:
  133.   exp_space = IIF(exp_space<16, 0, exp_space)
  134.  ENDIF
  135. ELSE                            && no 'E' param
  136.  exp_space = IIF(tot_exp>1024, 1024, tot_exp)   && gets all EMM
  137.  exp_space = IIF(exp_space<16, 0, exp_space)    && up to 1MB
  138. ENDIF
  139.  
  140. IF mem_vars<=0.OR.pool<=0
  141.  DO TERMINATE
  142. ENDIF
  143. * print results
  144. CLEAR
  145. ? "Approximate Memory Distribution for Clipper Autumn '86"
  146. ?
  147. ? 'Configuration:'
  148. ? ' Installed conventional memory:  '+STR(tot_conv)
  149. ? ' Installed expanded memory:      '+STR(tot_exp)
  150. ? ' DOS memory consumption:         '+STR(dos_size)
  151. ? ' Application memory consumption: '+STR(load_module)
  152. ? ' CLIPPER environment string:     '
  153. IF ' '=CLIPPER
  154.  ?? 'NONE'
  155. ELSE
  156.  ?? CLIPPER
  157. ENDIF
  158. ?
  159. ? 'Conventional Memory:'
  160. ? SUBSTR(' DOS'+SPACE(20),1,20)+STR(dos_size)
  161. ? SUBSTR(' Application module'+SPACE(20),1,20)+STR(load_module)
  162. ? SUBSTR(' Excluded'+SPACE(20),1,20)+STR(X)
  163. ? SUBSTR(' Memory variables'+SPACE(20),1,20);
  164.    +STR(INT(mem_vars+.5))
  165. IF exp_space > 0
  166.  ? SUBSTR(' RUN'+SPACE(20),1,20)+STR(INT(run_space+.5))
  167. ELSE
  168.  ? SUBSTR(' RUN+Indexing'+SPACE(20),1,20)+STR(INT(run_space+.5))
  169. ENDIF
  170. ? SUBSTR(' Free pool'+SPACE(20),1,20)+STR(INT(pool+.5))
  171. ?
  172. ? 'Expanded Memory:'
  173. ? SUBSTR(' Indexing'+SPACE(20),1,20)+STR(exp_space)
  174. ?
  175. ? '>>> All values approximate <<<'
  176. @ 22,0
  177. QUIT
  178.  
  179.  
  180. PROCEDURE TERMINATE
  181. CLEAR
  182. ?? CHR(7)
  183. TEXT
  184.  Error occurred.  Calling syntax is either:
  185.  
  186.    CLIPMEM tot_conv tot_exp dos_size load_module    (no commas)
  187.  
  188.                     or
  189.    CLIPMEM
  190.  
  191. You must supply either 4 or 0 command line parameters. If you do not
  192. supply them they are read internally from the current machine or 
  193. you are prompted for them. The current CLIPPER string is read from memory.
  194. Requires DOS 3.x or greater. Calculated values must be positive.
  195.  
  196. Significance of parameters:                              Allowed Range
  197.  
  198. tot_conv = amount of conventional memory installed (K)     256 -  640
  199. tot_exp  = amount of expanded memory installed               0 - 8192
  200. dos_size = size of DOS as loaded at runtime                 20 -  200
  201. load_module = size of your application's load module       100 -  600
  202. CLIPPER  = copy of the runtime CLIPPER environment string
  203. ENDTEXT
  204. @ 22,0
  205. QUIT
  206. RETURN
  207.